#pragma once

#include <iostream>
#include <string>
#include <error.h>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

using namespace std;

#define Mode 0666
#define Path "./fifo"

class Fifo
{
public:
    Fifo(const string& path)
        :_path(path)
    {
        
        int n = mkfifo(_path.c_str(), Mode);
        if(n < 0)
        {
            printf("create fifo fail, errno is %d, errinfo is %s\n", errno, strerror(errno));
        }
        else
        {
            printf("create fifo successfully\n");
        }
    }



    ~Fifo()
    {
        unlink(_path.c_str());
        printf("destroy fifo successfully\n");
    }
private:
    string _path;
};